<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

</head>

<body>
  <!-- 编写位置一: 编写在html内部 -->
  <a href="#" onclick="alert('百度一下')">百度一下</a>
  <a href="javascript:alert('百度一下')">百度一下</a>

  <!-- 编写位置二:编写在script元素之内 -->
  <a href="" class="google">Google一下</a>

  <script>
    var googleAEl = document.querySelector('.google')
    googleAEl.onclick = function () {
      alert("Google一下")
    }
  </script>

  <!-- 编写位置三:独立的js文件 -->
  <a href="#" class="bing">bing一下</a>
  <script src="./js/bing.js" />

</body>

</html>